package com.curtis.playwings;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.widget.ListView;

import com.curtis.playwings.ListView.Items;
import com.curtis.playwings.ListView.ItemsAdapter;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        startActivity(new Intent(this, SplashActivity.class));
        setContentView(R.layout.activity_main);
        
        //SHS
        ItemsAdapter adapter = new ItemsAdapter(this, generateData());
        
        // 2. Get ListView from activity_main.xml SHS
        ListView listView = (ListView) findViewById(R.id.listview);
 
        // 3. setListAdapter SHS
        listView.setAdapter(adapter);
    }
    
    private ArrayList<Items> generateData(){
    	
        ArrayList<Items> items = new ArrayList<Items>();
        
        //add item (needs parsing about airline info and switch airline info) SHS
        items.add(new Items("Korean Air","대한항공","blue","2014/01/28", "AAA", "BBB", "2014.01.01 ~ 2014.01.01", "TAX FREE", "70,000"));
        items.add(new Items("Asiana","아시아나","","2014/01/28", "AAA", "BBB", "2014.01.01 ~ 2014.01.01", "TAX FREE", "70,000"));
        items.add(new Items("Jeju Air","제주항공","","2014/01/28", "AAA", "BBB", "2014.01.01 ~ 2014.01.01", "TAX FREE", "70,000"));
 
        return items;
    }
    
    Handler mHandler = new Handler(){
    	public void handleMessage(android.os.Message msg) {
    		switch(msg.what){
    		case DataDownloadThread.MESSAGE_DOWNLOAD_END:
    			ArrayList<TicketData> data = (ArrayList<TicketData>)msg.obj;
    			Log.d("ryu","data airline "+data.get(0).airline);
    			break;
    		}
    	}
    };

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
